package com.mayikt.service.impl;

import com.mayikt.base.BaseApiService;
import com.mayikt.base.BaseResponse;
import com.mayikt.dto.resp.OrderRspDto;
import com.mayikt.entity.OrderEntity;
import com.mayikt.mapper.OrderMapper;
import com.mayikt.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;
import java.util.List;


@RestController
public class OrderServiceImpl extends BaseApiService implements OrderService {
    @Autowired
    private OrderMapper orderMapper;

    @Override
    public BaseResponse<String> addOrder() {
        for (int i = 0; i < 100; i++) {
            Long userId = 1L;
            orderMapper.addOrder(i + "", userId);
        }
        return setResultSuccess();
    }

    @Override
    public  BaseResponse<OrderRspDto> findByOrderId(Long orderId) {
        OrderEntity orderEntity = orderMapper.findByOrderId(orderId);
        OrderRspDto orderRspDto = dtoToDo(orderEntity,OrderRspDto.class);
        return setResultSuccess(orderRspDto);
    }

    @Override
    public List<String> listOrderId() {
        return orderMapper.findListOrders();
    }
}
